package com.acwing.partition12;

import java.io.*;
import java.util.Arrays;

/**
 * @author `RKC`
 * @date 2022/2/10 10:19
 */
public class AC1192奖金_SCC_拓扑排序 {

    private static final int N = 10010, M = 20010;
    private static int[] head = new int[N], hs = new int[N], ver = new int[M], next = new int[M], w = new int[M];
    private static int[] stk = new int[N], dist = new int[N], dfn = new int[N], low = new int[N], scc = new int[N], sccSize = new int[N];
    private static boolean[] inStk = new boolean[N];

    private static int n = 0, m = 0, idx = 0, top = 0, timestamp = 0, sccCnt = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        n = Integer.parseInt(ss[0]);
        m = Integer.parseInt(ss[1]);
        for (int i = 0; i < N; i++) head[i] = hs[i] = -1;
        for (int i = 0; i < m; i++) {
            ss = reader.readLine().split(" ");
            int a = Integer.parseInt(ss[0]), b = Integer.parseInt(ss[1]);
            //a>=b+1
            add(head, b, a, 1);
        }
        //a>=0+100
        for (int i = 1; i <= n; i++) add(head, 0, i, 100);
        //做一遍tarjan找环
        for (int i = 0; i <= n; i++) {
            if (dfn[i] == 0) tarjan(i);
        }
        //缩点
        for (int i = 0; i <= n; i++) {
            for (int j = head[i]; j != -1; j = next[j]) {
                int a = scc[i], b = scc[ver[j]];
                if (a == b) {
                    //存在环，无解
                    writer.write("Poor Xed\n");
                    writer.flush();
                    return;
                } else {
                    add(hs, a, b, w[j]);
                }
            }
        }
        //scc的编号逆序就是拓扑序
        for (int i = sccCnt; i > 0; i--) {
            for (int j = hs[i]; j != -1; j = next[j]) {
                int v = ver[j];
                dist[v] = Math.max(dist[v], dist[i] + w[j]);
            }
        }
        int sum = 0;
        for (int i = 1; i <= sccCnt; i++) sum += sccSize[i] * dist[i];
        writer.write(sum + "\n");
        writer.flush();
    }

    private static void tarjan(int u) {
        dfn[u] = low[u] = ++timestamp;
        stk[++top] = u;
        inStk[u] = true;
        for (int i = head[u]; i != -1; i = next[i]) {
            int v = ver[i];
            if (dfn[v] == 0) {
                tarjan(v);
                low[u] = Math.min(low[u], low[v]);
            } else if (inStk[v]) {
                low[u] = Math.min(low[u], dfn[v]);
            }
        }
        if (low[u] == dfn[u]) {
            int v = -1;
            sccCnt++;
            do {
                v = stk[top--];
                inStk[v] = false;
                scc[v] = sccCnt;
                sccSize[sccCnt]++;
            } while (u != v);
        }
    }

    private static void add(int[] head, int a, int b, int c) {
        ver[idx] = b;
        next[idx] = head[a];
        head[a] = idx;
        w[idx++] = c;
    }
}
